System and method for outputting character sets in best available fonts

ABSTRACT

A system and method of identifying the matching or best-matching font to output text of indeterminate language are presented. Today&#39;s operating systems do not provide the native tools and functions to easily display text of unknown language or multiple languages. The complexity of any underlying code that handles a multilingual display is sharply increased due to the text being segmented into multiple text runs. The invention employs character set engine that provides necessary character set guessing functionality, as well as an enumerator module to build a linked list of suitable output fonts to display text from an arbitrary language, and multilingual text. Output can be granted by traversing that list.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application claims priority from, and incorporates by reference,U.S. Provisional application serial No. 60/114,574 filed Dec. 31, 1998.The subject matter of this application is related to the subject matterof copending U.S. patent application Ser. Nos. 09/384,541, 09/384,089,and 09/384,538, entitled “System and Method For Using Character SetMatching To Enhance Print Quality,” “System and Method For Output OfMultipart Documents,” and “System and Method For Highlighting OfMultiFont Documents,” respectively, each having the same inventor asthis application and each being assigned or under obligation ofassignment to the same assignee as this application, each filed the sameday as this application, and each incorporated by reference. The subjectmatter of this application is also related to the subject matter ofcopending U.S. patent application Ser. Nos. 09/384,443, 09/384,371,09/384,442, and 09/384,088, entitled “System and Method For EvaluatingCharacter Sets,” “System and Method For Evaluating Character Sets ToDetermine A Best Match Encoding A Message,” “System and Method ForEvaluating Character Sets Of A Message Containing A Plurality ofCharacter Sets,” and “System and Method For Evaluating Character Sets ToGenerate A Search Index,” respectively, each filed the same day as thisapplication and each being assigned or under obligation of assignment tothe same assignee as this application, and each also incorporated byreference.

FIELD OF THE INVENTION

The invention relates to the field of communications, and moreparticularly to the management of character set information withindocuments so that the most appropriate font may be used to display oroutput documents which have an arbitrary language origin.

BACKGROUND OF THE INVENTION

With the use of the Internet, email and related electronic services,communications software has been increasingly called upon to handle datain a variety of formats. While the barriers to simple communicationshave been removed from many hardware implementations, the problem ofsoftware being unable to display text in different languages remains.

For instance, a person browsing the World Wide Web may wish to input asearch string in their native language. Some Web pages or search engineswill simply accept that string in the form in which it was input, butnot process the spelling, syntax or character set in native form. Thesearch engine then performs a search as though the search were inEnglish, usually resulting in no hits. Other Web pages may allow user tomanually specify the desired language for browsing and searching.

To display multilingual data correctly on the output side when adocument is located and ready to be outputted on a computer screen, sentto a printer or otherwise using the right font is a common problem thatdevelopers encounter when writing international applications, includingWeb applications.

In the pursuit of better and more uniform multilingual documents, theInternational Standards Organization (ISO) and other bodies havedeveloped a universal character set standard referred to as Unicode,Version 2.0 of which was released in 1996. The current Unicode standardis a 16-bit protocol encoding 25 different scripts as well as at least38,885 separate characters. Scripts are in general higher-levelcollections of related characters from a character set which may beassembled for use in one or more languages.

Ultimately, displaying Unicode data becomes a problem of dynamicallyselecting the closest font available on a system to best express asubject document. The commercial TrueType™ and OpenType™ font sets canonly output the appropriate glyphs or symbols for a subset of Unicoderanges. It is therefore necessary to generate the right character set(charset) font flag information, that is, to identify the font bestmatching the data to be displayed when creating the graphical fontobject for display or printing.

Unfortunately, documents often originate from unknown sources andunknown languages and even if the original text is encoded in Unicode,it can be difficult to identify in which character set or Unicode targetrange the content has been encoded with. Once the character set isidentified, it can be mapped to the corresponding font flag informationused to create the logical font under a given operating system. Forexample, text that can be encoded as Code page 874 would be mapped toTHAI_CHARSET in Microsoft™ Windows™.

The display of Unicode data consequently relates to a process ofselecting a font and using whatever system application programminginterface (API) is available to output the text, a process which becomeseven more complicated when the text is in multiple languages. Becausethe selected font might not be able to render all the characters fromall the different character sets used in multipart, multilanguagedocuments, that type of data must be broken into different textualsegments that use the same character set and display them separatelyusing the appropriate font.

Therefore, among other technical complexities, the software developermust solve at least two fundamental problems when trying to accommodatemultilingual output. The first is to determine which character set orUnicode ranges the text has been encoded with. The second, to choose thefont that will be able to render the characters most correctly. Otherproblems exist.

SUMMARY OF THE INVENTION

The invention overcoming these and other problems in the art relates toa system and method for embedding character set information in fonts, inwhich large-capacity fonts containing symbols applicable to a variety oflanguages include font tag information representing their capabilities.Application software, operating system software and other resources maytherefore interrogate the font tag information to determine whether agiven font may represent the characters of a message on acharacter-by-character basis. A linked list of matching fonts is built,which may be traversed to output the document to a screen display,printer or elsewhere. Textual documents having more than one languagemay be analyzed in successive runs, in which the most suitable font isselected for each segment for printing or other output.

BRIEF DESCRIPTION OF THE DRAWINGS

The invention will be described with respect to the accompanyingdrawings, in which like numbers represent like elements.

FIG. 1 illustrates an overall system for character set communicationaccording to the invention.

FIG. 2 illustrates the encoding layout for the Unicode standard.

FIG. 3 illustrates the relationship between big fonts, characters,scripts and other entities according to the invention.

FIG. 4 illustrates the operation of an enumerator module according tothe invention for generating a link list of fonts.

FIG. 5 illustrates the operation of a font manager module according tothe invention.

FIG. 6 illustrates the relationship between a big font object andUnicode encoding.

FIG. 7 illustrates a multipart document for output according to theinvention.

FIG. 8 illustrates a text run object for separating individual portionsof a multiple language document for different font expression accordingto the invention.

FIG. 9 illustrates an embodiment of the invention implemented in a LotusNotes™/Domino™ environment.

FIG. 10 illustrates the transmission of a message over a networkaccording to the invention.

FIG. 11 illustrates a method of selecting a font in which to output amessage according to one embodiment of the invention.

DETAILED DESCRIPTION OF THE ILLUSTRATIVE EMBODIMENTS

First, one illustrative environment in which the invention operates willbe described, in which documents to be processed are assumed to bestored in the Unicode format. Unicode is a 16-bit universal characterencoding that encompasses virtually all characters commonly used in thelanguages of today's world. Unicode encodes text by scripts, and notnecessarily by individual languages.

The Unicode standard assigns the same code point to characters orideographs that are shared among multiple languages, even though thesecharacters may have different meanings and pronunciations in thosedifferent languages. For this reason, one character can be rendered bymore than one glyph or symbol from different character sets, and thiscan potentially add logical errors to the displayed text.

Scripts can be defined as a higher-order collection of relatedcharacters which can be assembled to form one or more languages. Forexample, Cyrillic script can be used for the expression of Russian,Ukrainian, Bulgarian and other languages. Hebrew script can be used toexpress Modem Hebrew, Biblical Hebrew, and other languages. Each scripthas its own properties and rules, including logical order (right toleft, left to right, neutral), dynamic composition, ligature and otherattributes.

Ultimately, it is the responsibility of the font resources to implementthe rules and behaviors proper to each script as outlined by the Unicodestandard. For a font to be Unicode conformant, it must correctlyinterpret and render a subset of Unicode characters, providing supportfor one or many specific scripts and languages. To avoid ambiguity, theinvention helps to transparently identify the language or character setbeing used in the data so that a best match to available output fontsmay be made.

Otherwise, in the absence of the invention the operating system wouldhave to select whatever default language is available in the givenscript. This can result in character rendering errors. Therefore, theinvention operates to choose the optimal font for display as well as toselect the correct script in the font, and may query the font propertiesand display the text output according to correct rules of language.Moreover, the invention may process texts composed in several differentlanguages, one after the other for output. An illustration of theoverall text processing according to the invention is shown in FIG. 10.

The Unicode standard uses different ranges for each of its constituentscripts, as illustrated in FIG. 2. Given a character code point withinthe 16-bit address range of Unicode, it is straightforward usingUnicode's encoding layout to identify the corresponding script bylocation. But because a single script can be used by more than onelanguage, it is only by looking at the surrounding text and usingstatistical methods that the character set of the original language canbe determined with any degree of certainty.

It should be noted that ASCII characters are used in nearly all scriptsand therefore do not reveal significant information about the originallanguage. Conversely, the presence of idiosyncratic characters which arestrongly associated with particular languages can be used to infer theuse of that language in the original text. For example, Hiraganacharacters in a stream of Han ideographs is a strong indication that thetext is Japanese, and a stream of Hangul characters is almost certainlyKorean. Other scripts have known associations with various particularlanguages.

In general, in terms of character set evaluation or identification theinvention uses a character table bank against which the ability of anumber of character sets to encode a given character is tested. When amessage of unknown origin is presented to the system, its characters areparsed and tested against the character table bank to identify which ofthe pool of character sets can express each character.

A character set which contains a match for every character of themessage is likely to be the native encoding of the original message.Tallies of matches to individual characters across all availablecharacter sets in the character table bank can also be made for themessage as a whole. An overall architecture of a character set analysissystem is illustrated in FIG. 1.

The invention in one regard uses statistical methods to provide anautomatic and rigorous language evaluation facility by which the textrepresented in Unicode is tested against a bank of available languagecharacter sets, in order to determine which or any of those candidatecharacter sets can express the text in its entirety. The inventionevaluates which character sets are capable of expressing the text fromthe language bank, to present to a user or otherwise.

The invention may assign a rating to those character sets that canexpress the given message, in order to determine which of the charactersets is the most appropriate to use to express the message. Theinvention may likewise evaluate which character set permits searchingand reading of text expressions, improving the quality of searchresults, all as more fully described in the aforementioned copendingU.S. application Ser. Nos. 09/384,541, 09/384,089, 09/389,538,09/384,443, 09/384,371, 09/384,442, and 09/384,088.

As illustrated in FIG. 3, fonts which are capable of representingcharacters from multiple scripts are referred to as big fonts 502.Within a big font 502, scripts are identified by font tag 504 thatencodes information about the capabilities of that font, including anindication of scripts which employ the characters of that font. In oneembodiment the font tag may comprise a unique 4-byte identifier, butother formats are contemplated by the invention. Furthermore, asillustrated in FIG. 6, in the particular environment of True Type™fonts, big fonts 502 may be tagged with a font signature 506 thatcontains information about the Unicode subranges currently supported.

FIG. 11 illustrates an operation of selecting a font to output amultipart message according to one embodiment of the invention. In anoperation 1102, a message is received. In an operation 1104, a eachcharacter of each portion of the message is evaluated using Font Tags.In an operation 1106, a linked list of available system fonts matchingeach character of the each portion of the message is created. In anoperation 1108, the linked list of available system fonts is traversedto determine which font is most suitable to render each portion of themessage. In an operation 1110, the each portion of the message is outputusing fonts in the traversed list.

For example, Microsoft Windows™ uses the following structure to exchangefont signature information.

TABLE 1 Typedef struct tagFONTSIGNATURE { DWORD fsUsb[4]; //Unicodesubranges DWORD fsCsb[2]; //Windows and OEM code pages } FONTSIGNATURE;

Individual applications can query big fonts about their multilingualcapabilities by accessing the font tag 504 according to the invention.More specifically, client software can inquire whether a given font maybe able to render the text of a current document correctly. Microsoft™Windows™ provides the following function to obtain the font signature ofa font currently selected in a Device context, as will be understood bypersons skilled in the art.

TABLE 2 int WINAPI GetTextCharsetInfo(HDC hdc, LPFONTSIGNATURE lpSig,DWORD dwFlags);

The procedure call in Table 2 above can only be used, however, tovalidate a given font for matching a character set which is alreadyspecified. To dynamically select an appropriate font, the inventioninstead enumerates all the fonts available in the system and organizesthem by name. In the practice of the invention, and as illustrated inFIGS. 4 and 5, this enumeration function is generally done atinitialization time by creating a linked list of structures that containvarious categories of information about the native fonts. Each font namecategory then contains a list of all the scripts supported, as well asthe graphical font objects associated with that script. The outputtingof a subject text to a screen display, printer or otherwise cantherefore be performed by traversing the linked list. FIGS. 4 and 5adhere to the syntax of the C++ language, although it will be understoodthat other programming languages may be used.

As illustrated in FIG. 5, the CUnicodeFontManager module 516 contains alinked list of CFamilyFont modules 518, each of which contains aCUnitFontInfoManager module 522 that contains a linked list object 520containing a sequence of CUnitFontInfo objects 524 identifying scriptsassociated with or capable of expressing a given symbol. Outputting thesubject text is then a matter or traversing the linked list to invokethe fonts associated with the CUnitFontInfo objects 524, to send to adisplay screen, printer or otherwise.

To build the linked list object 520, the following Windows™ function maybe used.

TABLE 3 int EnumFontFamiliesEx(HDC, LPLOGFONT, //pointer to logical fontFONTENUMPROC,//pointer to callback function LPARAM,//application-supplied data DWORD); //reserved; must be zero

In this environment, the callback function passed to the procedure callEnumFontFamiliesEx must have the following prototype.

TABLE 4 int CALLBACK EnumFontFamExProc( ENUMLOGFONTEXW *lpelfe, //pointer to logical-font data NEWTEXTMETRICEXW *lpntme, // pointer tophysical-font data int FontType, // type of font LPARAM lparam); //application-defined data

Inside the callback function in Table 4 above, the linked list object520 can be built using the data passed by the system. In the particularenvironment of Microsoft™ Windows™, the character set used is actually afont character set which does not necessarily match the character set orcode page that is returned by the integrated character set guessingalgorithm of the invention. Therefore, in one embodiment it is necessaryto map the code page to a font character set property, before doing alookup query to the linked list object 520 of available fonts.

The code in Table 5 below is as an example under Microsoft™ Windows™ ofsuch a code page mapping.

TABLE 5 BYTE MapCodePageToFontCharset(short iActiveCodePage) {switch(iActiveCodePage) { case 874: Return THAI_CHARSET; case 932:Return SHIFTJIS_CHARSET; case 936: Return GB2312_CHARSET; case 949:Return HANGEUL_CHARSET; case 950: Return CHINESEBIG5_CHARSET; case 1250:Return EASTEUROPE_CHARSET; case 1251: Return RUSSIAN_CHARSET; case 1252:Return ANSI_CHARSET; case 1253: Return GREEK_CHARSET; case 1254: ReturnTURKISH_CHARSET; case 1255: Return HEBREW_CHARSET; case 1256: ReturnARABIC_CHARSET; case 1257: Return BALTIC_CHARSET; default: break; }Return DEFAULT_CHARSET; }

If a client application working in tandem with the invention to processtext needs to create a graphical font object, that application will needto use a return flag when creating a logical font structure according tothe invention. For further example in Windows™:

TABLE 6 BYTE FlagCharset=MapCodePageToFontCharset( iActiveCodePage);LOGFONT lFont; (Initialization of lFont . . . ) LFont.lfCharSet =FlagCharset; CreateFontIndirect ( &lFont); . . .

When the font has been created and selected into a Device context, itmay then be necessary to query information such as ordering, ligature,existence of additional glyphs that are not encoded, and otherinformation for output presentation. Windows™ provides the followingfunction to access these properties:

DWORD WINAPI GetFontLanguageInfo(HDC);

Another Windows™ function which is useful in this regard is:

TABLE 7 DWORD WINAPI GetCharacterPlacement( HDC, // handle to devicecontext LPCSTR,  //pointer to string Int, // number of characters instring Int, //maximum extent for display LPGCP_RESULTS, //Result bufferDWORD); //placement flags

The procedure call GetCharacterPlacement can be used to queryinformation from font tag 504 about a displayed string such as itswidth, ordering, glyph rendering and other information that may be usedby client applications or otherwise to adjust the output document.

Another embodiment of the invention involving documents made up ofsections in different languages will now be described. Using thecharacter guessing algorithm described more fully in the aforementionedcopending U.S. application Ser. Nos. 09/384,541, 09/384,089, 09/384,538,09/384,371, 09/384,442, and 09/384,088, the text-rendering subsystemfirst segments the text into multiple text runs that share the samecharacter set or Unicode range. In general, the invention managesmultipart, multilanguage documents by decomposing them into discretesegments for output.

FIG. 7 illustrates the decomposition of a multilingual text. For eachsegment, the invention looks up the preloaded list of system fonts toselect the appropriate font. Once every segment is assigned a correctfont, the entire text is displayed, as illustratively implemented in thecode of the following Table 8.

TABLE 8 For (each segment) { Load font into Device Context Display textin segment Unload font }

An additional difficulty in a multipart context is the increasedcomplexity that is introduced in functions such as word wrapping, cursormovement, text highlighting and other graphically oriented operations.This is because multiple text segments must be juggled, and for eachtextual segment, properties such as selected font, text position(coordinate of the Xstart and Ystart for the string), caret position,and other information must be tracked.

The object CCTextRunList illustrated in FIG. 8 encapsulates a list ofccTextRun objects 524 to manage the operations of such features,including to generate a multipart linked list object 526. The followingprocedure call is intended to create this linked list object 526.

TABLE 9 While (Not end of text) {   EvaluateTextcharset();  Build textrun with same charset . . .  Add new TextRun in List( . . . ); }

The invention uses the technique described above to display the data ina multipart, multilanguage environment. In this case, the invention mustlikewise address complications to common word processing and otherfunctions like text highlighting, text cursor placement, cursormovement, and so forth. The complexity for implementing these featuresis increased by the fact that the text is decomposed into multiplesegments or runs. For example, to compute the extent of the text, inthis embodiment the invention separately computes the extent of eachsegment and then adds them together.

TABLE 10 SIZE GetMutilingualTextExtent(HDC hdc) { SIZE RetSize; For(each segment) { Load font into Device Context Compute extent forsegment Add the size to RetSize; Unload font } Return RetSize; }

Because more than one font is involved in the display process, the sizeof the text displayed in each segment can vary considerably. Therefore,a once simple operation, such as highlighting the text, can become veryinvolved in this embodiment. The invention therefore needs to computethe smallest rectangle that contains the whole text to assist inhighlighting and other functions. To improve performance, thisinformation is stored as part of the ccTextRunList objects 524, andupdated during outputting to screen, printer or otherwise.

Managing the caret position and movement also requires specialattention. Again this is because the text is separated into multiplesegments, and the invention thus needs a function that gets the nextcharacter. In this embodiment, the invention stores a current positionpointer 528 to the current text segment as illustrated in FIG. 7, aswell as a set of other pointers including the illustrated begin textpointer 530, end of segment 1 pointer 532 (first segment illustrated butbegin/end pointers for other segments being contemplated), and end oftext pointer 534.

TABLE 11 Short GetNextCharacter() { If(end of segment) Select nextsegment If (no more segment) Return End of text Get next character incurrent segment Return next character; }

Once the character is returned, it is straightforward to retrieve itswidth using the font identified for the segment. The invention in thisembodiment may process as many segments are necessary to properly encodethe text for output. Different scripts may appear one or more times inthe aggregate document.

Another environment of the invention relating to the Lotus Domino™Global WorkBench™ illustrated in FIG. 9. Lotus Domino™ Global WorkBench™is a tool used for the localization of Notes™ databases and Web sites.It must correctly render the data stored in Note™ databases, which use aLotus-proprietary universal character set (Lotus MultiByte CharacterSet, or LMBCS) that is converted to Unicode for output, no matter whatthe language version of the operating system used at run time. In aNotes™ environment as shown, once conversion to Unicode is carried out,output font processing may be performed as described above.Alternatively, the enumerator and other modules of the invention may beconfigured to directly operate on the Notes™-native character code.

The foregoing description of the system and method of the invention isillustrative, and variations in configuration and implementation willoccur to persons skilled in the art. For example, while the output ofcharacters has been described with respect to display on a computermonitor or printing, other types of output such as facsimile and otherscan be performed. The scope of the invention is accordingly intended tobe limited only by the following claims.

What is claimed is:
 1. A method of selecting a font in which to output amessage, the message including a plurality of characters, comprising:(a) evaluating the message to build a list of fonts for each characterin the plurality of characters in the message, each of said list offonts built from a plurality of available system fonts, each font ineach of said list of fonts able to render said each character associatedtherewith; and (b) outputting the message by traversing each of saidlist of fonts for each of said plurality of characters to determine themost suitable font for said plurality of characters.
 2. The method ofclaim 1, wherein the evaluating of step (a) comprises the step ofcomparing each character of the message in a universal code to a set ofavailable system fonts.
 3. The method of claim 2, wherein the step ofcomparing each character comprises the step of testing the ability ofeach of the set of available system fonts to express that character. 4.The method of claim 2, wherein the universal code is Unicode.
 5. Themethod of claim 1, further comprising the step of (c) generating a codepage using at least one of the available system fonts.
 6. A system forselecting a font in which to output a message, the message including aplurality of characters, comprising: a processor unit, the processorunit evaluating the message to build a list of fonts for each characterin the plurality of characters in the message, each of said list offonts built from a plurality of available system fonts, each font ineach of said list of fonts able to render said each character associatedtherewith; and an output interface, connected to the processor unit, tooutput the characters of the message by traversing each of said list offonts for each of said plurality of characters to determine the mostsuitable font for said plurality of characters.
 7. The system of claim6, wherein the processor unit compares each character of the message ina universal code to a set of available system fonts.
 8. The system ofclaim 7, wherein the processor unit tests the ability of each of the setof available system fonts to express that character.
 9. The system ofclaim 8, wherein the universal code is Unicode.
 10. The system of claim6, wherein the processor unit generates a code page using at least oneof the available system fonts.
 11. A system for selecting a font inwhich to output a message, the message including a plurality ofcharacters, comprising: processor means, the processor means evaluatingthe message to build a list of fonts for each character in the pluralityof characters in the message, each of said list of fonts built from aplurality of available system fonts, each font in each of said list offonts able to render said each character associated therewith; andoutput interface means, connected to the processor means, to output thecharacters of the message by traversing each of said list of fonts foreach of said plurality of characters to determine the most suitable fontfor said plurality of characters.
 12. The system of claim 11, whereinthe processor means compares each character of the message in auniversal code to a set of available system fonts.
 13. The system ofclaim 12, wherein the processor means tests the ability of each of theavailable system fonts to express that character.
 14. The system ofclaim 13, wherein the universal code is Unicode.
 15. The system of claim11, wherein the processor generates a code page using at least one ofthe available system fonts.
 16. A storage medium for storing machinereadable code, the machine readable code being executable to select afont in which to output a message, the message including a plurality ofcharacters, the medium comprising: (a) evaluating the message to build alist of fonts character in the plurality of characters in the message,each of said list of fonts built from a plurality of available systemfonts, each font in each of said list of fonts able to render said eachcharacter associated therewith; and (b) outputting the message bytraversing each of said list of fonts for each of said plurality ofcharacters to determine the most suitable font for said plurality ofcharacters.
 17. The storage medium of claim 16, wherein the evaluatingof step (a) comprises the step of comparing each character of themessage in a universal code to a set of available system fonts.
 18. Thestorage medium of claim 17, wherein the step of comparing each charactercomprises the step of testing the ability of each of the set ofavailable system fonts to express that character.
 19. The storage mediumof claim 18, wherein the universal code is Unicode.
 20. The storagemedium of claim 16, further comprising the step of (c) generating a codepage using at least one of the available system fonts.
 21. A method ofselecting a font in which to output a message, comprising: (a) comparingeach of a plurality of characters in the message against a list ofavailable system fonts; (b) generating a list of fonts for eachcharacter in said plurality of characters, each font in each of saidlist of fonts able to render said each character associated therewith;and (c) traversing each of said list of fonts to determine the mostsuitable font in which to render the message.